package com.it.bigdata.schedual.impl;

import com.it.bigdata.schedual.Schedual;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque;

public class BaiDuTieBaSchedualForQueue implements Schedual {
    private long currentPageNum = 0L;
    private static final BaiDuTieBaSchedualForQueue bdQueue = new BaiDuTieBaSchedualForQueue();
    private BaiDuTieBaSchedualForQueue(){}
    public static BaiDuTieBaSchedualForQueue getBdQueue(){
        return bdQueue;
    }
    //高并发的队列是用来存储文章的url列表，让调度器来调度
    private Queue<String> queue = new ConcurrentLinkedDeque<String>();
    /**
     * 给调度器添加元素
     */
    public void push(String str){
        queue.offer(str);
    }


    /**
     * 从资源调度器中获取元素
     */

    public String pop(){
        return queue.poll();
    }
    public void nextPage() {
        currentPageNum += 50;
    }
    public Long getCurrentPageNum() {
        return currentPageNum;
    }
}
